package com.uroad.jilinpda.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;


import com.uroad.jilinpda.R;
import com.uroad.jilinpda.common.BaseActivity;
import com.uroad.jilinpda.common.GlobalData;
import com.uroad.jilinpda.util.UIUtils;
import com.uroad.jilinpda.widget.TripDialog;
import com.uroad.lib.widget.dialog.DialogHelper;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.jzvd.JzvdStd;


/**
 * @创建者 wlw
 * @创建时间 2019/6/3 12:17
 * @描述
 */
public class OBUActivationStep1Activity extends BaseActivity {
    @BindView(R.id.ivTrips)
    ImageView ivTrips;
    @BindView(R.id.iv_ring2)
    ImageView iv_ring2;
    @BindView(R.id.tv_step2)
    TextView tv_step2;
    @BindView(R.id.view_lien2)
    View lien2;
    @BindView(R.id.llvideo)
    LinearLayout llvideo;
    @BindView(R.id.videoTrips)
    JzvdStd videoTrips;
    private String isneedpic;
    private String vehtype = "";
    private TripDialog tripDialog;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setBaseContentLayout(R.layout.activity_obu_activation_step_1);
        ButterKnife.bind(this);
        setTitle("标签激活");
        initView();
//        initVedioView();
    }

    private void initVedioView() {
        videoTrips.setUp(GlobalData.obu_activation_video_url_1, "");
        videoTrips.backButton.setVisibility(View.GONE);
    }

    private void showTripDialog() {
        tripDialog.showCancelBtn(false);
        tripDialog.setTitle("温馨提示");
        tripDialog.setContent("还未激活完成，请不要让用户带走设备，以免后续产生拒付纠纷");
        tripDialog.setbtnConfirm("我知道了");
        tripDialog.setOnDialogClickListener(new TripDialog.OnDiglogClickListener() {
            @Override
            public void onConfirm() {
                tripDialog.dismiss();

            }

            @Override
            public void onCancel() {
                DialogHelper.endLoading();
                tripDialog.dismiss();
                finish();
                //                if (isShowUpdateDialog) {
                //                    if (isMustUpdate) {
                //                        finish();
                //                        System.exit(0);
                //                    }
                //                }
            }
        });
        tripDialog.show();
    }

    @Override
    protected void onResume() {
        super.onResume();
//        videoTrips.startVideo();
    }

    @Override
    protected void onPause() {
        super.onPause();
//        Jzvd.resetAllVideos();
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
//        if (Jzvd.backPress()) {
//            return;
//        }
    }

    private void initView() {
        UIUtils.setViewScale(ivTrips, 670, 376);
//        UIUtils.setViewScale(llvideo, 670, 376);
        Bundle bundle = getIntent().getExtras();
        if (bundle != null) {
            isneedpic = bundle.getString("isneedpic");
            vehtype = bundle.getString("vehtype");
            if ("0".equalsIgnoreCase(isneedpic)) {
                iv_ring2.setVisibility(View.GONE);
                lien2.setVisibility(View.GONE);
                tv_step2.setVisibility(View.GONE);
            }
        }
        tripDialog = new TripDialog(this);
        tripDialog.setDismissAble(false);
        showTripDialog();
    }

    @OnClick({R.id.btnNext1})
    public void onClick(View view) {
        Bundle bundle = getIntent().getExtras();
        if (bundle == null)
            bundle = new Bundle();
        bundle.putString("vehtype", vehtype);
        if ("0".equalsIgnoreCase(isneedpic)) {
            openActivity(OBUActivationStep3Activity.class,bundle);
        }else{
            openActivity(OBUActivationStep2Activity.class,bundle);
        }
    }
}
